import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';

import { MyApp } from './app.component';



import { LoginPageModule } from '../pages/login/login.module'
import { DevicePageModule } from '../pages/device/device.module'
import { UserPageModule } from '../pages/user/user.module'
import { AlarmPageModule } from '../pages/alarm/alarm.module'
import { BadPageModule } from '../pages/bad/bad.module'
import { MsgPageModule } from '../pages/msg/msg.module'
import { DirectivesModule } from '../directives/directives.module'
import { PipesModule } from '../pipes/pipes.module'

import { TabsPage } from '../pages/tabs/tabs';
import { HomeListPage } from '../pages/home/home-list/home-list';
import { HomePage } from '../pages/home/home';
import { AboutPage } from '../pages/about/about';

import { ListPage } from '../pages/list/list';

import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

import { IonJPushModule } from 'ionic2-jpush';

import { HttpModule } from '@angular/http';
import { AppGlobal } from '../providers/appGlobal';
import { HttpService } from '../providers/httpService';
import { JpushService } from '../providers/jpushService';
import { DeviceProvider } from '../providers/service/device';
import { UserProvider } from '../providers/service/user';
import { MsgProvider } from '../providers/service/msg';
import { AnalysisProvider } from '../providers/service/analysis';
// import { from } from 'rxjs/observable/from';

// import { AmAgoTimePipe } from '../pipes'


let pages: any = [
  TabsPage,
  AboutPage,
  MyApp,
  HomePage,
  HomeListPage,
  ListPage
  // AbcComponent
]

export function declarations() {
  return pages;
}

export function entryComponents() {
  return pages;
}

export function providers() {
  return [
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler},
    AppGlobal,    //全局变量
    HttpService,  //http服务
    JpushService,   //jpush
    DeviceProvider,  //设备工厂
    UserProvider,    //用户工厂
    MsgProvider,    //消息工厂
    AnalysisProvider    //分析工厂
  ];
}

@NgModule({
  declarations: declarations(),
  imports: [
    IonJPushModule,
    BrowserModule,
    HttpModule,
    DirectivesModule,
    PipesModule,
    LoginPageModule,
    DevicePageModule,
    UserPageModule,
    AlarmPageModule,
    BadPageModule,
    MsgPageModule,
    IonicModule.forRoot(MyApp, {
        backButtonText: '返回',
        mode: 'ios' 
    }),
  ],
  bootstrap: [IonicApp],
  entryComponents: entryComponents(),
  providers: providers()
})
export class AppModule {}
